Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bignumber.js

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bignumber.js

A library for arbitrary-precision decimal and non-decimal arithmetic

  • 6.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14M
increased by4.74%
Maintainers
1
Weekly downloads
 
Created

What is bignumber.js?

The bignumber.js package is a JavaScript library for arbitrary-precision decimal and non-decimal arithmetic. It allows for high-precision calculations that are necessary when dealing with very large or very small numbers that cannot be accurately represented with JavaScript's native Number type.

What are bignumber.js's main functionalities?

Arithmetic Operations

Perform precise arithmetic operations such as addition, subtraction, multiplication, and division.

"use strict"; const BigNumber = require('bignumber.js'); let x = new BigNumber(123.4567); let y = new BigNumber('123456.7e-3'); let z = x.plus(y); console.log(z.toString()); // '246.9134'

Chaining Methods

Allows for method chaining to perform multiple operations sequentially on a BigNumber instance.

"use strict"; const BigNumber = require('bignumber.js'); let result = new BigNumber('111.1111111').plus('0.0000001').times('3').sqrt().toPrecision(10); console.log(result); // '1.732050808'

Comparison

Compare two BigNumber instances to determine the relational state.

"use strict"; const BigNumber = require('bignumber.js'); let a = new BigNumber('2'); let b = new BigNumber('3'); console.log(a.isLessThan(b)); // true

Rounding

Round a BigNumber to a specified number of decimal places.

"use strict"; const BigNumber = require('bignumber.js'); let number = new BigNumber('123.4567'); let rounded = number.toFixed(2); console.log(rounded); // '123.46'

Conversion

Convert a BigNumber to a different base or to a string representation.

"use strict"; const BigNumber = require('bignumber.js'); let number = new BigNumber('123456.789e-3'); let inBase10 = number.toString(10); console.log(inBase10); // '123.456789'

Other packages similar to bignumber.js

Keywords

FAQs

Package last updated on 26 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc